package com.me.hippy.sdk

import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.fragment.app.FragmentActivity
import com.hippy.lib.utils.ConvertUtils
import com.hippy.lib.utils.SPUtils
import com.hippy.lib.utils.ToastUtils
import com.me.hippy.sdk.demo.chat.AiliaoChatActivity
import com.me.hippy.sdk.demo.chat.AiliaoChatActivity2
import com.me.hippy.sdk.demo.chat.ChatActivity

class MainActivity : FragmentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setInitStatusBar()
        setContentView(R.layout.activity_main)

        findViewById<View>(R.id.btn_crash).setOnClickListener {
            val aa = 10 / 0

        }


        ToastUtils.showLong(
            "哈哈 测试一下: ${ConvertUtils.dp2px(10f)} ${
            SPUtils.getInstance().getString("key")
            }"
        )
        SPUtils.getInstance().put("key", "哈哈哈", true)

        startActivity(Intent(this, ChatActivity::class.java))
    }

    private fun setInitStatusBar() {
        if (Build.VERSION.SDK_INT >= 21) {
            window.addFlags(Int.MIN_VALUE)
            window.clearFlags(67108864)
            window.statusBarColor = 0xffffffff.toInt()
        }
        val i = Build.VERSION.SDK_INT
        if (i >= 23) {
            window.decorView.systemUiVisibility = 9216
        } else if (i >= 21) {
            window.statusBarColor = 0xff000000.toInt()
        }
    }
}